package com.cqrcb.cloud.config.redis.config;

import com.cqrcb.cloud.config.redis.constant.RedisTools;
import org.redisson.connection.ConnectionListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.net.InetSocketAddress;

public class MyConnectionListener implements ConnectionListener {

    private RedisTools redisTools;

    public MyConnectionListener(RedisTools redisTools) {
        this.redisTools = redisTools;
    }

    @Override
    public void onConnect(InetSocketAddress addr) {
        System.out.println("链接成功");
    }

    @Override
    public void onDisconnect(InetSocketAddress addr) {
        System.out.println("链接失败");
        redisTools.getAndSetRedisAvailable();
    }
}